package com.lemon.util;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class CommanUtil {

    public static String runCmd(String cmdPath){
        String res = "";
        try {
            //String shpath = "/data/hadoop/percisettask/2_merge_userlog.sh";
            Process ps = Runtime.getRuntime().exec(cmdPath);
            ps.waitFor();

            BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));
            StringBuffer sb = new StringBuffer();
            String line;
            while ((line = br.readLine()) != null) {
                sb.append(line).append("\n");
            }
            res = sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
            res = "执行出错";
        }
        return res+"---"+cmdPath;
    }

}
